package com.antd.common.sms.listener;

import com.antd.admin.api.entity.SysSmsLog;
import com.antd.common.sms.event.SmsLogEvent;
import com.antd.common.sms.fegin.RemoteSmsLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;

/**
 * TODO
 *
 * @author 子丶沫
 * @version 1.0
 * @date 2020/12/2 11:28
 */
@Slf4j
public class SysSmsLogListener {
    @Autowired
    private RemoteSmsLogService remoteSmsLogService;

    @EventListener(SmsLogEvent.class)
    @Async
    public void saveSmsLog(SmsLogEvent smsLogEvent){
        SysSmsLog sysSmsLog= (SysSmsLog) smsLogEvent.getSource();
        log.info("保存成功:{}",sysSmsLog);
        remoteSmsLogService.saveSmsLog(sysSmsLog);
    }
}
